```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MySQL脚本全面指南 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-self;
            background-color: #f8f9fa;
            color: #333;
        }
        .hero {
            background: linear-gradient(135deg, #6B73FF 0%, #000DFF 100%);
        }
        .code-block {
            background-color: #2d3748;
            border-radius: 8px;
            padding: 1.5rem;
            position: relative;
        }
        .code-block pre {
            margin: 0;
            overflow-x: auto;
        }
        .code-block code {
            color: #e2e8f0;
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.9rem;
        }
        .section-card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .section-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(107, 115, 255, 0.2);
            z-index: -1;
            transform: skewY(-2deg);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:py-28">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">MySQL脚本<br>数据库操作的<span class="highlight">艺术与科学</span></h1>
                    <p class="text-xl opacity-90 mb-8">探索结构化查询语言的精髓，掌握数据库开发的核心技能</p>
                    <div class="flex space-x-4">
                        <a href="#ddl" class="bg-white text-blue-600 hover:bg-blue-50 px-6 py-3 rounded-lg font-medium transition duration-300">开始学习</a>
                        <a href="#visualization" class="border-2 border-white text-white hover:bg-white hover:text-blue-600 px-6 py-3 rounded-lg font-medium transition duration-300">关系图谱</a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative w-full max-w-md">
                        <div class="absolute -top-6 -left-6 w-24 h-24 bg-yellow-400 rounded-lg opacity-20"></div>
                        <div class="absolute -bottom-6 -right-6 w-24 h-24 bg-pink-400 rounded-lg opacity-20"></div>
                        <div class="relative bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg p-6 rounded-xl border border-white border-opacity-20 shadow-xl">
                            <div class="flex items-center mb-4">
                                <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                                <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                                <div class="w-3 h-3 rounded-full bg-green-500"></div>
                            </div>
                            <div class="code-block">
                                <pre><code>-- 示例：创建数据库和表
CREATE DATABASE ecommerce;
USE ecommerce;

CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    price DECIMAL(10,2) NOT NULL,
    stock INT DEFAULT 0
);</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-6xl px-4 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-database text-blue-600 text-xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold">MySQL脚本概述</h2>
                </div>
                <p class="text-lg text-gray-700 leading-relaxed mb-6">
                    MySQL脚本是一组用于执行数据库操作的SQL语句和命令的文本集合。这些脚本可以包含数据库和表的创建、数据的插入、查询、更新、删除，以及存储过程、触发器等数据库对象的定义和操作。
                </p>
                <p class="text-lg text-gray-700 leading-relaxed">
                    在数据库开发和维护中，MySQL脚本起到关键作用，可以通过执行脚本来进行数据库的初始化、更新和维护。在实际应用中，也常常使用脚本来自动化执行一系列数据库操作，确保数据库结构和数据的一致性。
                </p>
            </div>
        </section>

        <!-- DDL Section -->
        <section id="ddl" class="mb-20">
            <div class="section-card bg-white rounded-xl shadow-md overflow-hidden">
                <div class="flex flex-col md:flex-row">
                    <div class="md:w-1/3 bg-blue-50 p-8 flex flex-col justify-center">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
                                <i class="fas fa-table text-blue-600"></i>
                            </div>
                            <h2 class="text-2xl font-bold">数据定义语言 (DDL)</h2>
                        </div>
                        <p class="text-gray-700 mb-4">DDL用于定义数据库和表的结构，包括创建、修改和删除数据库对象。</p>
                        <div class="flex items-center text-sm text-blue-600">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>创建数据库和表</span>
                        </div>
                        <div class="flex items-center text-sm text-blue-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>修改表结构</span>
                        </div>
                        <div class="flex items-center text-sm text-blue-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>删除数据库对象</span>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="code-block">
                            <pre><code>-- 创建数据库
CREATE DATABASE IF NOT EXISTS mydatabase;
USE mydatabase;

-- 创建表
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL
);

-- 修改表结构
ALTER TABLE users ADD COLUMN age INT AFTER email;

-- 删除表
DROP TABLE IF EXISTS temp_table;</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- DML Section -->
        <section class="mb-20">
            <div class="section-card bg-white rounded-xl shadow-md overflow-hidden">
                <div class="flex flex-col md:flex-row-reverse">
                    <div class="md:w-1/3 bg-green-50 p-8 flex flex-col justify-center">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center mr-4">
                                <i class="fas fa-edit text-green-600"></i>
                            </div>
                            <h2 class="text-2xl font-bold">数据操作语言 (DML)</h2>
                        </div>
                        <p class="text-gray-700 mb-4">DML用于对数据库中的数据进行操作，包括增删改查等基本操作。</p>
                        <div class="flex items-center text-sm text-green-600">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>插入数据 (INSERT)</span>
                        </div>
                        <div class="flex items-center text-sm text-green-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>查询数据 (SELECT)</span>
                        </div>
                        <div class="flex items-center text-sm text-green-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>更新数据 (UPDATE)</span>
                        </div>
                        <div class="flex items-center text-sm text-green-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>删除数据 (DELETE)</span>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="code-block">
                            <pre><code>-- 插入数据
INSERT INTO users (username, email) 
VALUES ('user1', 'user1@example.com'),
       ('user2', 'user2@example.com');

-- 查询数据
SELECT * FROM users WHERE username = 'user1';

-- 更新数据
UPDATE users SET email = 'new_email@example.com' 
WHERE username = 'user1';

-- 删除数据
DELETE FROM users WHERE username = 'user1';</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Stored Procedures Section -->
        <section class="mb-20">
            <div class="section-card bg-white rounded-xl shadow-md overflow-hidden">
                <div class="flex flex-col md:flex-row">
                    <div class="md:w-1/3 bg-purple-50 p-8 flex flex-col justify-center">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
                                <i class="fas fa-cogs text-purple-600"></i>
                            </div>
                            <h2 class="text-2xl font-bold">存储过程和函数</h2>
                        </div>
                        <p class="text-gray-700 mb-4">存储过程和函数用于封装一系列SQL语句，实现可重用的业务逻辑。</p>
                        <div class="flex items-center text-sm text-purple-600">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>提高代码复用性</span>
                        </div>
                        <div class="flex items-center text-sm text-purple-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>增强安全性</span>
                        </div>
                        <div class="flex items-center text-sm text-purple-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>提升性能</span>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="code-block">
                            <pre><code>-- 存储过程示例
DELIMITER //
CREATE PROCEDURE GetUserById(IN userId INT)
BEGIN
    SELECT * FROM users WHERE id = userId;
END //
DELIMITER ;

-- 调用存储过程
CALL GetUserById(1);

-- 函数示例
DELIMITER //
CREATE FUNCTION GetUserCount() 
RETURNS INT
BEGIN
    DECLARE userCount INT;
    SELECT COUNT(*) INTO userCount FROM users;
    RETURN userCount;
END //
DELIMITER ;

-- 调用函数
SELECT GetUserCount();</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Triggers Section -->
        <section class="mb-20">
            <div class="section-card bg-white rounded-xl shadow-md overflow-hidden">
                <div class="flex flex-col md:flex-row-reverse">
                    <div class="md:w-1/3 bg-yellow-50 p-8 flex flex-col justify-center">
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-yellow-100 rounded-lg flex items-center justify-center mr-4">
                                <i class="fas fa-bolt text-yellow-600"></i>
                            </div>
                            <h2 class="text-2xl font-bold">触发器</h2>
                        </div>
                        <p class="text-gray-700 mb-4">触发器在特定数据库事件发生时自动执行，用于实现数据完整性约束和业务规则。</p>
                        <div class="flex items-center text-sm text-yellow-600">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>BEFORE/AFTER 触发器</span>
                        </div>
                        <div class="flex items-center text-sm text-yellow-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>INSERT/UPDATE/DELETE 事件</span>
                        </div>
                        <div class="flex items-center text-sm text-yellow-600 mt-2">
                            <i class="fas fa-check-circle mr-2"></i>
                            <span>FOR EACH ROW 语法</span>
                        </div>
                    </div>
                    <div class="md:w-2/3 p-8">
                        <div class="code-block">
                            <pre><code>-- 在插入前自动格式化email
CREATE TRIGGER before_insert_users
BEFORE INSERT ON users
FOR EACH ROW
SET NEW.email = LOWER(NEW.email);

-- 在更新时记录修改时间
CREATE TRIGGER before_update_users
BEFORE UPDATE ON users
FOR EACH ROW
SET NEW.updated_at = NOW();

-- 删除关联数据的级联触发器
CREATE TRIGGER after_delete_user
AFTER DELETE ON users
FOR EACH ROW
DELETE FROM user_logs WHERE user_id = OLD.id;</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section id="visualization" class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8">
                <div class="flex items-center mb-8">
                    <div class="w-12 h-12 bg-indigo-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-project-diagram text-indigo-600 text-xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold">MySQL脚本核心概念关系图</h2>
                </div>
                <div class="mermaid bg-gray-50 p-6 rounded-lg">
                    graph TD
                        A[MySQL脚本] --> B[数据定义语言 DDL]
                        A --> C[数据操作语言 DML]
                        A --> D[存储过程/函数]
                        A --> E[触发器]
                        A --> F[事务管理]
                        A --> G[权限控制]
                        
                        B --> B1[CREATE]
                        B --> B2[ALTER]
                        B --> B3[DROP]
                        
                        C --> C1[INSERT]
                        C --> C2[SELECT]
                        C --> C3[UPDATE]
                        C --> C4[DELETE]
                        
                        D --> D1[参数传递]
                        D --> D2[流程控制]
                        D --> D3[返回值]
                        
                        E --> E1[BEFORE/AFTER]
                        E --> E2[INSERT/UPDATE/DELETE]
                        
                        F --> F1[START TRANSACTION]
                        F --> F2[COMMIT]
                        F --> F3[ROLLBACK]
                        
                        G --> G1[GRANT]
                        G --> G2[REVOKE]
                </div>
            </div>
        </section>

        <!-- Additional Sections -->
        <div class="grid md:grid-cols-2 gap-8 mb-20">
            <!-- Transaction Section -->
            <div class="section-card bg-white rounded-xl shadow-md p-6">
                <div class="flex items-center mb-4">
                    <div class="w-10 h-10 bg-red-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-exchange-alt text-red-600"></i>
                    </div>
                    <h3 class="text-xl font-bold">事务管理</h3>
                </div>
                <p class="text-gray-700 mb-4">事务确保一组SQL语句要么全部执行成功，要么全部不执行，保证数据一致性。</p>
                <div class="code-block">
                    <pre><code>START TRANSACTION;

-- 一系列SQL语句
INSERT INTO orders (user_id, amount) 
VALUES (1, 100.00);

UPDATE accounts 
SET balance = balance - 100.00
WHERE user_id = 1;

-- 根据条件提交或回滚
COMMIT; -- 或 ROLLBACK;</code></pre>
                </div>
            </div>
            
            <!-- Permissions Section -->
            <div class="section-card bg-white rounded-xl shadow-md p-6">
                <div class="flex items-center mb-4">
                    <div class="w-10 h-10 bg-teal-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-user-shield text-teal-600"></i>
                    </div>
                    <h3 class="text-xl font-bold">权限控制</h3>
                </div>
                <p class="text-gray-700 mb-4">精确控制用户对数据库对象的访问权限，保障数据安全。</p>
                <div class="code-block">
                    <pre><code>-- 授予权限
GRANT SELECT, INSERT, UPDATE 
ON mydatabase.* 
TO 'app_user'@'localhost' 
IDENTIFIED BY 'secure_password';

-- 撤销权限
REVOKE DELETE 
ON mydatabase.* 
FROM 'app_user'@'localhost';

-- 刷新权限
FLUSH PRIVILEGES;</code></pre>
                </div>
            </div>
            
            <!-- Optimization Section -->
            <div class="section-card bg-white rounded-xl shadow-md p-6">
                <div class="flex items-center mb-4">
                    <div class="w-10 h-10 bg-orange-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-tachometer-alt text-orange-600"></i>
                    </div>
                    <h3 class="text-xl font-bold">索引与优化</h3>
                </div>
                <p class="text-gray-700 mb-4">通过索引和查询优化提高数据库性能。</p>
                <div class="code-block">
                    <pre><code>-- 创建索引
CREATE INDEX idx_username ON users(username);
CREATE INDEX idx_email ON users(email(20));

-- 查看执行计划
EXPLAIN SELECT * FROM users 
WHERE username = 'admin' 
AND status = 'active';

-- 优化表
OPTIMIZE TABLE users;</code></pre>
                </div>
            </div>
            
            <!-- Batch Section -->
            <div class="section-card bg-white rounded-xl shadow-md p-6">
                <div class="flex items-center mb-4">
                    <div class="w-10 h-10 bg-pink-100 rounded-lg flex items-center justify-center mr-4">
                        <i class="fas fa-clone text-pink-600"></i>
                    </div>
                    <h3 class="text-xl font-bold">批量操作</h3>
                </div>
                <p class="text-gray-700 mb-4">一次性执行多条SQL语句，提高操作效率。</p>
                <div class="code-block">
                    <pre><code>-- 批量插入
INSERT INTO products (name, price, stock)
VALUES 
    ('Product A', 19.99, 100),
    ('Product B', 29.99, 50),
    ('Product C', 9.99, 200);

-- 批量更新
UPDATE products 
SET price = CASE 
    WHEN id = 1 THEN 21.99
    WHEN id = 2 THEN 31.99
    WHEN id = 3 THEN 11.99
END
WHERE id IN (1, 2, 3);</code></pre>
                </div>
            </div>
        </div>

        <!-- Conclusion -->
        <section class="bg-blue-50 rounded-xl shadow-md p-8 mb-20">
            <div class="text-center">
                <h2 class="text-2xl md:text-3xl font-bold mb-6">MySQL脚本的强大功能</h2>
                <p class="text-lg text-gray-700 mb-8 max-w-3xl mx-auto">
                    MySQL脚本在数据库开发和维护中扮演着核心角色，从基础的CRUD操作到复杂的事务处理和性能优化，掌握这些脚本编写技巧将极大提升您作为数据库开发人员的效率和能力。
                </p>
                <div class="grid md:grid-cols-2 lg:grid-cols-4 gap-4 max-w-4xl mx-auto">
                    <div class="bg-white rounded-lg p-4 shadow-sm">
                        <div class="text-blue-600 text-2xl mb-2"><i class="fas fa-layer-group"></i></div>
                        <h4 class="font-bold mb-1">结构化</h4>
                        <p class="text-sm text-gray-600">清晰的层次结构</p>
                    </div>
                    <div class="bg-white rounded-lg p-4 shadow-sm">
                        <div class="text-green-600 text-2xl mb-2"><i class="fas fa-cogs"></i></div>
                        <h4 class="font-bold mb-1">自动化</h4>
                        <p class="text-sm text-gray-600">批量执行任务</p>
                    </div>
                    <div class="bg-white rounded-lg p-4 shadow-sm">
                        <div class="text-purple-600 text-2xl mb-2"><i class="fas fa-shield-alt"></i></div>
                        <h4 class="font-bold mb-1">安全</h4>
                        <p class="text-sm text-gray-600">权限控制机制</p>
                    </div>
                    <div class="bg-white rounded-lg p-4 shadow-sm">
                        <div class="text-orange-600 text-2xl mb-2"><i class="fas fa-tachometer-alt"></i></div>
                        <h4 class="font-bold mb-1">高效</h4>
                        <p class="text-sm text-gray-600">性能优化工具</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索技术的无限可能</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        <span>访问我们的语雀空间</span>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-sm text-gray-500 text-center">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <!-- Mermaid JS -->
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```